home *** CD-ROM | disk | FTP | other *** search
/ Aminet 31 / Aminet 31 (1999)(Schatztruhe)[!][Jun 1999].iso / Opus5.5 / ARexx.lha / ARexx / PlayMod_MP.dopus5 < prev    next >
Text File  |  1996-06-13  |  5KB  |  144 lines

  1. /* Mod-Player interface for Directory Opus 5.5
  2.    by Leo 'Nudel' Davidson for Gods'Gift Utilities
  3.    email: leo.davidson@keble.oxford.ac.uk  www: http://users.ox.ac.uk/~kebl0364
  4.  
  5. $VER: PlayMod_MP.dopus5 1.5 (13.6.96)
  6.  
  7.    This version is for use with MultiPlayer by Bryan Ford, but should be
  8.    easy to adapt to any other player with an ARexx port, such as
  9.    Eagle/DeliTracker, DMP, etc.
  10.    (In fact, a DeliTracker version should come with this script!).
  11.  
  12.    If you include the path of a module on the command line, using {f}, only
  13.    this mod will be played. If you omit the {f}, the program will play each
  14.    selected file in the first SOURCE lister, giving you a requester to go to
  15.    the next file or stop playing.
  16.  
  17.    If the player's ARexx port is not found, the program will be run for
  18.    you (you should edit the path below). This means the script may fail if
  19.    you disable the player's ARexx port, or give an incorrect command line
  20.    to it.
  21.    If the player's ARexx port takes over a minute to appear, an error
  22.    requester will appear on the DOpus screen and the script will quit.
  23.    REMEMBER to add the "RUN" command to the player command line if it does
  24.    not automatically detach from the shell (MultiPlayer does)!
  25.  
  26.    If the player was running to start with, or the user selects
  27.    "Leave Playing", the module will continue playing when the script finishes.
  28.    Otherwise, the player will be quit.
  29.  
  30. Call as:
  31. ------------------------------------------------------------------------------
  32. ARexx    DOpus5:ARexx/PlayMod_MP.dopus5 {Qp} [{f}]
  33. ------------------------------------------------------------------------------
  34. Turn off all switches.
  35. "[]" means this part is optional.
  36.  
  37. //- Path to MultiPlayer command --------------------------------------------*/
  38. MultiPlayer = "DH0:Tools/Music/MultiPlayer"
  39. /*--------------------------------------------------------------------------*/
  40. options results
  41. options failat 99
  42. signal on syntax;signal on ioerr        /* Error trapping */
  43. parse arg DOpusPort FilePath
  44. DOpusPort = Strip(DOpusPort,"B",'" ')
  45. /* Important: FilePath must be stripped as below incase there is a space at
  46.               the beginning or end of the filename */
  47. FilePath = Strip(Strip(FilePath,"B",' '),"B",'"')
  48.  
  49. If DOpusPort="" THEN Do
  50.     Say "Not correctly called from Directory Opus 5!"
  51.     Say "Load this ARexx script into an editor for more info."
  52.     EXIT
  53.     END
  54. If ~Show("P",DOpusPort) Then Do
  55.     Say DOpusPort "is not a valid port."
  56.     EXIT
  57.     End
  58. Address value DOpusPort
  59.  
  60. dopus version
  61. If ( result='RESULT' | translate(result,'.',' ') < 5.1218 ) then do
  62.     dopus request '"This script requires DOpus v5.5 or greater." OK'
  63.     EXIT
  64.     end
  65.  
  66. Quit_After = "NO"
  67. If ~Show("P","RXTRACKER") Then Do
  68.     Address Command MultiPlayer "NOREQUEST"
  69.     Address Command "WaitForPort RXTRACKER"
  70.     Quit_After = "YES"
  71.     If ~Show("P","RXTRACKER") then do
  72.         dopus request '"Error loading MultiPlayer!'|| '0a'x ||'Check its command-path in the ARexx script itself." OK'
  73.         EXIT
  74.         END
  75.     END
  76.  
  77. /* If file-path was specified on command line, just play that mod, else
  78.    go through all the selected ones. */
  79.  
  80. If FilePath = "" Then Do
  81.     lister query source stem source_handle.
  82.     IF source_handle.count = 0 | source_handle.count = "SOURCE_HANDLE.COUNT" Then Do
  83.         dopus request '"You must have a SOURCE lister!" OK'
  84.         EXIT
  85.         End
  86.     lister set source_handle.0 busy 1
  87.  
  88.     lister query source_handle.0 numselentries    /* Get info about selected */
  89.     Lister_NumSelEnt = RESULT            /* entries & path to them */
  90.     lister query source_handle.0 path
  91.     Lister_Path = Strip(RESULT,"B",'"')
  92.  
  93.     Do i=1 to Lister_NumSelEnt
  94.         lister query source_handle.0 firstsel
  95.         Temp_Name = Strip(RESULT,"B",'"')
  96.         lister select source_handle.0 Temp_Name 0
  97.         Temp_Path = Lister_Path || Temp_Name
  98.         Address RXTRACKER Load Temp_Path;Address RXTRACKER Play
  99.  
  100.         If Lister_NumSelEnt - i > 0 Then Do
  101.             If Quit_After = "YES" Then
  102.                 lister request source_handle.0 '"Playing module' i 'of' Lister_NumSelEnt || ':' || X2C(0A) || Temp_Name || '" Next|Leave Playing|Stop'
  103.             Else
  104.                 lister request source_handle.0 '"Playing module' i 'of' Lister_NumSelEnt || ':' || X2C(0A) || Temp_Name || '" Next|Leave Playing'
  105.             IF RC = "0" THEN BreakIt = "YES"
  106.             IF RC = "2" THEN Do
  107.                 BreakIt = "YES"
  108.                 Quit_After = "NO"
  109.                 END
  110.             End
  111.  
  112.         Else Do
  113.             If Quit_After = "YES" Then
  114.                 lister request source_handle.0 '"Playing module' i 'of' Lister_NumSelEnt || ':' || X2C(0A) || Temp_Name || '" Leave Playing|Stop'
  115.             Else
  116.                 lister request source_handle.0 '"Playing module' i 'of' Lister_NumSelEnt || ':' || X2C(0A) || Temp_Name || '" Leave Playing'
  117.             IF RC = "1" Then Quit_After = "NO"
  118.             End
  119.  
  120.         IF BreakIt = "YES" THEN BREAK
  121.         END
  122.     End
  123.  
  124. ELSE Do
  125.     Address RXTRACKER Load FilePath;Address RXTRACKER Play
  126.     If Quit_After = "YES" Then
  127.         dopus request '"Playing module:' || X2C(0A) || FilePath || '" Leave Playing|Stop'
  128.     Else
  129.         dopus request '"Playing module:' || X2C(0A) || FilePath || '" Leave Playing'
  130.     IF RC ~= "0" THEN Quit_After = "NO"
  131.     End
  132.  
  133. /*-- Restore the Lister for normal use --------------------------------------*/
  134. syntax:;ioerr:                /* In case of error, jump here */
  135. END_PART_2:
  136. If FilePath = "" Then Do
  137.     lister refresh source_handle.0
  138.     lister set source_handle.0 busy 0
  139.     END
  140. END_PART:
  141. If Quit_After = "YES" Then Address RXTRACKER QUIT
  142.  
  143. EXIT
  144.